/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2022/8/26 21:41
 * 通过实现Runnable接口，重写run()方法，实现线程的创建
 *      实现Runnable接口，重写run()方法,再创建Thread类，
 *      把MyRunnable实例化对象作为Thread构造方法的参数传入
 *
 */

class MyRunnable implements Runnable{
    @Override
    public void run() {
        while (true){
            System.out.println("hello Runnable Thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class ThreadDemo3 {
    public static void main(String[] args) {
        Thread t = new Thread(new MyRunnable());
        t.start();

        while(true){
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
